/**
 * @author SHIXINGXING
 */

/* 新增社交 */
function add(){
    window.self.location="social.do?method=addSocial";
}
/* 删除社交 */
function del(pageNum, socialDate){
    var flag = false;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            flag = true;
        }
    }
    if (!flag) {
        alert("请选择需要删除的社交！");
        return;
    }
    if (window.confirm("确认删除吗？")) {  
        with (document.getElementById("list")) {       
            method = "post";
            action = "social.do?method=delSocial&pageNum=" + pageNum + "&socialDate="+socialDate;
            submit();
        }
    }
}
/* 编辑社交 */
function edit(pageNum,socialDate){
    var count = 0;
    var j = 0;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            j = i;
            count++;
        }
    }
    if (count == 0) {
        alert("请选择需要修改的社交！");
        return;
    }
    if (count > 1) {
        alert("一次只能修改一个社交！");
        return;
    }
    if (count == 1) {
        window.self.location = "social.do?method=editSocial&socialID=" +
        document.getElementsByName("ids")[j].value + "&pageNum=" + pageNum + "&socialDate="+socialDate;
    }
}

// 翻页
function turnPage(oper,pageNum,totalPage,action,socialDate){  
    var myPageNum = 1;             
    if(oper == "first"){ 
         myPageNum = 1; 
    }       
    if(oper == "last"){ 
        myPageNum = (Number)(totalPage); 
    }       
    if(oper == "up"){ 
        myPageNum = (Number)(pageNum) - 1; 
    }       
    if(oper == "down"){ 
        myPageNum = (Number)(pageNum) + 1; 
    }       
    if(oper == "to"){ 
        var toPageNum = (Number)(document.getElementById("text").value);                
        if(toPageNum == "0"){ 
            alert("页数不能为0!!"); 
            return; 
        }                
        if(toPageNum > (Number)(totalPage)){ 
            alert("页数过大!!"); 
            return; 
        } 
        myPageNum = toPageNum; 
    }            
    var form = document.getElementById("list"); 
    form.action=" "+action+"?method=listSocialOfMonthByPage&pageNum="+myPageNum+"&socialDate="+socialDate; 
    form.submit(); 
} 